package com.example.config;


import com.alibaba.druid.pool.DruidDataSource;
import com.example.bean.Cat;
import com.example.bean.Dog;
import com.example.bean.Mouse;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Import;


//@Import(MyImportSelector.class)
@Import(Mouse.class)
public class SpringConfig {
    @Bean
//    @ConditionalOnClass(Mouse.class)
//    @ConditionalOnMissingClass({"com.example.bean.Mouse"})
    @ConditionalOnBean(name="jerry")
    @ConditionalOnMissingClass("com.example.bean.Dog")
//    @ConditionalOnWebApplication

    public Cat tom(){
        return new Cat();
    }

    @Bean
    @ConditionalOnClass(name = "com.mysql.jdbc.Driver")
    public DruidDataSource dataSource(){
        return new DruidDataSource();
    }


}
